package KVRMIService;

import java.rmi.Naming;

public class KVClient {

	public static void main (String[] args) {
		try {
			// Use the naming service to lookup a reference to the object
			System.out.println("Looking up the KVStore through the naming service");
			KVStoreInterface kvClient =
					(KVStoreInterface) Naming.lookup("KVStore");
			
			// Insert a key into the key value store
			System.out.println("Inserting a key value pair");
			kvClient.insert(1, "test value");
			
			// Lookup the value for the key
			System.out.println("Looking up the value for a key");
			String value = kvClient.lookup(1);
			System.out.println("Got value: " + value + " for key: " + 1);
		}
		catch (Exception e) {
			System.out.println("KVClient exception: " + e);
		}
	}
}
